package com.wuye.rcgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuye.common.annotation.Log;
import com.wuye.common.core.controller.BaseController;
import com.wuye.common.core.domain.AjaxResult;
import com.wuye.common.enums.BusinessType;
import com.wuye.rcgl.domain.WyGlc;
import com.wuye.rcgl.service.IWyGlcService;
import com.wuye.common.utils.poi.ExcelUtil;
import com.wuye.common.core.page.TableDataInfo;

/**
 * 管理处信息Controller
 * 
 * @author wpc
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/rcgl/glc")
public class WyGlcController extends BaseController
{
    @Autowired
    private IWyGlcService wyGlcService;

    /**
     * 查询管理处信息列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:glc:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyGlc wyGlc)
    {
        startPage();
        List<WyGlc> list = wyGlcService.selectWyGlcList(wyGlc);
        return getDataTable(list);
    }

    /**
     * 导出管理处信息列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:glc:export')")
    @Log(title = "管理处信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyGlc wyGlc)
    {
        List<WyGlc> list = wyGlcService.selectWyGlcList(wyGlc);
        ExcelUtil<WyGlc> util = new ExcelUtil<WyGlc>(WyGlc.class);
        util.exportExcel(response, list, "管理处信息数据");
    }

    /**
     * 获取管理处信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('rcgl:glc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyGlcService.selectWyGlcById(id));
    }

    /**
     * 新增管理处信息
     */
    @PreAuthorize("@ss.hasPermi('rcgl:glc:add')")
    @Log(title = "管理处信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyGlc wyGlc)
    {
        return toAjax(wyGlcService.insertWyGlc(wyGlc));
    }

    /**
     * 修改管理处信息
     */
    @PreAuthorize("@ss.hasPermi('rcgl:glc:edit')")
    @Log(title = "管理处信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyGlc wyGlc)
    {
        return toAjax(wyGlcService.updateWyGlc(wyGlc));
    }

    /**
     * 删除管理处信息
     */
    @PreAuthorize("@ss.hasPermi('rcgl:glc:remove')")
    @Log(title = "管理处信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyGlcService.deleteWyGlcByIds(ids));
    }

    /**
     * 查询管理处信息列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:glc:listAll')")
    @GetMapping("/listAll")
    public AjaxResult listAll()
    {
        return AjaxResult.success(wyGlcService.list());
    }
}
